const Promise = require('./promise');
console.log('Promise:',Promise);
Promise.try = function (fn) {
  return new Promise((resolve, reject) => {
    resolve(fn()); //如果fn()直接报错，相当于try{executor}catch(e){reject(e)}的时候报错，本promise就会被reject
  });
};

function fn() {
  throw new Error('123');
  return new Promise((resolve,reject) => {
    // throw new Error('error');
    /*setTimeout(() => {
      reject('345')
    }, 1000);*/
  });
}

Promise.try(fn).catch(err=>{
  console.log('err:',err);
})
